{% extends "base.html" %}

{% block content %}
{% import "m_mailview.html" as mailview %}

<div id="listmail">
	<h1>{{ mailbox }}</h1>
	<p>Messages in this mailbox: {{ nummsg }}</p>

	<div class="header">
		<span class="checkbox"><input type="checkbox" id="toggleallcheckboxes" onclick="ToggleAllCheckboxes()" title="Select/Deselect all" /></span>
		<span class="flags" title="Flags">F.</span>
		<span class="subject">Subject</span>
		<span class="from">From</span>
		<span class="date">Date</span>
	</div>

	{% for msg in messages %}
		{% set link = 'viewmail.php?mailbox=' ~ mailbox ~ '&uid=' ~ msg.uid %}

		{% if 'N' in msg.flags %}
			{% set new = ' new' %}
		{% else %}
			{% set new = '' %}
		{% endif %}

		<div class="row {{ loop.index is even ? 'shade' : 'noshade' }}{{ new }}">
			<span class="checkbox"><input type="checkbox" name="messages[{{ msg.uid }}]" /></span>
			<span class="flags">{{ msg.flags }}</span>
			<span class="subject" onclick="window.location.href='{{ link }}'"><a href="{{ link }}">{{ msg.subject }}</a></span>
			<span class="from" onclick="window.location.href='{{ link }}'"><a href="{{ link }}">[{{ msg.from }}]</a></span>
			<span class="date" onclick="window.location.href='{{ link }}'"><a href="{{ link }}">[{{ msg.date }}]</a></span>
		</div>
	{% endfor %}
</div>

{% endblock %}

{% block afterjs %}
<script>
	AddEvent(window, 'load', ColumnWidth);
	AddEvent(window, 'resize', ColumnWidth);
</script>

{% endblock %}
